<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h3 class="city"></h3>
    <script>
        const xhr = new XMLHttpRequest()
        // 携带查询参数 ?pname=辽宁省
        xhr.open('GET', 'http://hmajax.itheima.net/api/city?pname=辽宁省')
        xhr.addEventListener('loadend', () => {
            // JSON 字符串
            console.log(xhr.response);
            // 转对象  JSON
            const data = JSON.parse(xhr.response)
            console.log(data); // 对象
            // 数组 
            console.log(data.list); // 数组
            // 转字符串 join
            document.querySelector('.city').innerHTML = data.list.join('<br>')
            const str = '["沈阳市","大连市","鞍山市","抚顺市","本溪市","丹东市","锦州市","营口市","阜新市","辽阳市","盘锦市","铁岭市","朝阳市","葫芦岛市"]'
            console.log(JSON.parse(str));
        })
        xhr.send()
    </script>
</body>
</html>